#include <PA9.h>
#include "graphic.h"

namespace game{
    Graphic::Graphic(bool screen, void* objGraphic, u8 objShape, u8 objSize, u8 colorMode){
        Graphic::screen = screen;
        Graphic::objGraphic = objGraphic;
        Graphic::shape = objShape;
        Graphic::size = objSize;
        Graphic::colormode = colorMode;
    }
    
    void Graphic::load(){
        if(!loaded){
            graphicid = PA_CreateGfx(screen, objGraphic, shape, size, colormode);
            loaded = true;
        }
    }
    
    void Graphic::loaddual(){
        if(!loaded){
            u16 dualid[2];
            dualid[false] = PA_CreateGfx(false, objGraphic, shape, size, colormode);
            dualid[true] = PA_CreateGfx(true, objGraphic, shape, size, colormode);
            dualgraphicid = (u32)dualid;
            graphicid = dualid[screen];
        }
    }
    
    bool Graphic::isloaded(){
        return loaded;
    }
    
    void Graphic::remove(){
        PA_DeleteGfx(screen, graphicid);
        loaded = false;
    }
    
    Graphic::~Graphic(){
        remove();
    }
    
    u16 Graphic::getid(){
        return graphicid;
    }
    
    u32 Graphic::getdualid(){
        return dualgraphicid;
    }
    
    u8 Graphic::getshape(){
        return shape;
    }
    
    u8 Graphic::getsize(){
        return size;
    }
    
    u8 Graphic::getcolormode(){
        return colormode;
    }
}
